/**
 * Created by jbz on 2017/4/14.
 */
import {ALERT, SHOW_LOADING} from '../mutations-types';

const defaultAlertList = {
  okCallback: null,
  cancelCallback: null
};
const rootModule = {
  state: {
    showLoading: false,
    alertOptions: {
      alertList: defaultAlertList
    },
    activitySignal: {
      activityList: defaultAlertList
    },
    noSignal: {
      signalList: defaultAlertList
    },
    cityAlert: {
      show: false,
      title: '',
      okCallback: () => {
      },
      cancelCallback: () => {
      }
    }
  },
  mutations: {
    [SHOW_LOADING](state, bool) {
      state.showLoading = bool;
    },
    showAlert: function (state, options) {
      state.alertOptions = {alertList: defaultAlertList, ...options};
    },
    signalAlert: function (state, options) {
      state.noSignal = {signalList: defaultAlertList, ...options};
    },
    activityAlert: function (state, options) {
      state.activitySignal = {activityList: defaultAlertList, ...options};
    },
    [ALERT.CITY_ALERT]: function (state, cityAlert) {
      state.cityAlert = {...cityAlert};
    }
  }
};

export default rootModule;
